package com.tarena.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.smartstruts.action.Action;
import org.smartstruts.action.ActionForm;

import com.tarena.bo.EmpDao;
import com.tarena.util.FormUtils;
import com.tarena.vo.Dept;
import com.tarena.vo.Emp;

/**
 * 
 * 更新一个员工信息
 * 
 * @author WangPeihu
 * @since 05/01/2010
 * @Team [Never give up]
 */
public class UpdateEmpAction extends Action {
	private EmpDao ed = new EmpDao();

	@Override
	public String execute(ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		try {
			request.setCharacterEncoding("utf-8");
			Emp emp = new Emp();
			Dept dept = new Dept();
			emp.setDept(dept);
			FormUtils.populate(emp, request);
			if ("" != emp.getName().trim()) {
				ed.updateEmp(emp);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success";
	}
}
